/**
 * Created by limeng on 16/6/13.
 */
delegateApp.controller("WaitFeedbackProposalsCtrl", function ($scope, $http, $rootScope) {
    $scope.pageSize = 10;
    $scope.pageNo = 1;
    $scope.inputPageNo = 1;
    $scope.pageCount = 1;
    $scope.proposals = [];

    $scope.updateContent = function() {
        $http.post('/proposal/search', {
                pageSize : $scope.pageSize,
                pageNo : $scope.pageNo,
                proposalState : 6,
                hostDepartmentId : $rootScope.delegate.department.id
            }
        ).success(
            function (data) {
                if (data.state == true) {
                    $scope.proposals = data.list;
                    $scope.pageCount = data.pageCount;
                } else {
                    showAlert('查询失败', '原因是:'+data.result);
                }
            }
        ).error(
            function () {
                showAlert('查询失败', '请联系开发者进行维护');
            }
        );
    };
    $scope.previousPage = function () {
        $scope.pageNo = ($scope.pageNo - 1) < 1 ? 1 : --$scope.pageNo;
        $scope.updateContent();
    };
    $scope.nextPage = function() {
        $scope.pageNo = ($scope.pageNo + 1) >= $scope.pageCount ? $scope.pageCount : ++$scope.pageNo;
        $scope.updateContent();
    };
    $scope.jumpPage = function () {
        if ($scope.inputPageNo > 0 && $scope.inputPageNo <= $scope.pageCount) {
            $scope.pageNo = parseInt($scope.inputPageNo);
            $scope.updateContent();
        } else {
            $scope.inputPageNo = 1;
        }
    };

    $scope.updateContent();
});